import express from 'express';
import { createSchema, createYoga } from 'graphql-yoga';
import { typeDefs } from './schema/typeDefs.generated'
import { resolvers } from './schema/resolvers.generated'

export function buildApp(app: ReturnType<typeof express>) {
  const graphQLServer = createYoga({ schema: createSchema({ typeDefs, resolvers }) })

  app.use(graphQLServer.graphqlEndpoint, graphQLServer);

  return graphQLServer.graphqlEndpoint;
}
